<%@ tag body-content="scriptless" dynamic-attributes="dynattrs"
        pageEncoding="windows-1252" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@ taglib prefix="agent" uri="http://gettestfire.org/taglibs/agent" %>


<%@ attribute name="userName" required="true" rtexprvalue="true" type="java.lang.String" %>
<%@ attribute name="useForm" required="true" rtexprvalue="true" type="java.lang.Boolean" %>
<jsp:useBean id="tsList" class="org.testfire.agent.bean.TestsetBean" scope="request"/>


<jsp:setProperty name="tsList" property="*"/>
<c:set var="sets" value="${tsList.testsetPaths}"/>
<c:choose>
    <c:when test="${empty sets}">
        <h3> No Testsets saved for user ${userName}</h3>
    </c:when>
    <c:otherwise>
        <c:if test="${useForm}">
            <form action="/testsetManager.jsp?userName=${tsList.userName}" method="POST">
        </c:if>
        <div style="width:70%;margin-left:15%;text-align:center;">
            <label for="userName_">UserName: </label>
            <input id="userName_" type="text" name="userName" size="20" value="${userName}">
        </div>
        <table style="width:70%;margin-left:15%;" border="2" cellpadding="2">
            <thead>
                <tr style="font-weight:bold;font-size:120%">
                    <td style="width:60%;">Testset</td>
                    <td style="width:40%;text-align:center;">
                        All <input type="checkbox" id="all" name="testset" value="all"/>
                    </td>
                </tr>
            </thead>
            <tbody>
                <c:forEach items="${sets}" var="testset">
                    <tr style="border-width:2px;border-color:black">
                        <td>${testset}</td>
                        <td style="text-align:center;">
                            <input id="${testset}" name="testset" value="${testset}" type="checkbox"/>
                        </td>
                    </tr>
                </c:forEach>
            </tbody>
            <tfoot>
                <tr>
                    <td style="text-align:center;">
                        <select id="selectAction" name="action" style="width:50%">
                            <option id="action_run" value="ACTION_RUN">Run</option>
                            <option id="action_delete" value="ACTION_DELETE">Delete</option>
                        </select>
                    </td>
                    <td style="text-align:center;">
                        <input type="submit" value="Go"/>
                    </td>
                </tr>
            </tfoot>
        </table>
        <c:if test="${empty param.noform}">
            </form>
        </c:if>
        <br/><br/><br/><br/><br/>
        <c:set var="testsets" value="${tsList.testsets}" />
        <c:forEach items="${testsets}" var="testset" varStatus="status">
            <agent:list_testsetResults testset="${testset}"/><br/><br/>
        </c:forEach>
    </c:otherwise>

</c:choose>
